<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>运动识别检测</title>
    <style>
        body {
            background-image: url("{{ url_for('static', filename='bc.png') }}");
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
            height: 100vh;
            margin: 0;
            padding: 0;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            font-family: Arial, sans-serif;
        }
        h1 {
            margin-bottom: 20px;
        }
        form {
            background-color: rgba(255, 255, 255, 0.8);
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
            max-width: 400px;
            width: 100%;
            position: relative; /* 让加载动画相对于表单进行定位 */
        }
        form label, form select, form input[type="file"], form input[type="submit"] {
            display: block;
            margin-bottom: 15px;
        }
        form input[type="submit"] {
            background-color: #4CAF50;
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 5px;
            cursor: pointer;
        }
        form input[type="submit"]:hover {
            background-color: #45a049;
        }
        /* 加载动画样式 */
        .loading {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 50px;
            height: 50px;
            border: 3px solid #f3f3f3;
            border-radius: 50%;
            border-top: 3px solid #3498db;
            width: 30px;
            height: 30px;
            -webkit-animation: spin 2s linear infinite; /* Safari */
            animation: spin 2s linear infinite;
            display: none; /* 初始状态隐藏加载动画 */
        }
        /* Safari 浏览器兼容性 */
        @-webkit-keyframes spin {
            0% { -webkit-transform: rotate(0deg); }
            100% { -webkit-transform: rotate(360deg); }
        }
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
    </style>
</head>
<body>
    <h1>运动识别检测</h1>
    <form id="detectionForm" action="/index" method="post" enctype="multipart/form-data" onsubmit="showLoading()">
        <label for="mode">选择检测模式：</label>
        <select name="mode" id="mode">
            <option value="1">从本地导入视频检测</option>
            <option value="2">调用摄像头检测</option>
        </select>
        <label for="exercise">选择运动类型：</label>
        <select name="exercise" id="exercise">
            <option value="1">俯卧撑</option>
            <option value="2">深蹲</option>
        </select>
        <label for="file">上传视频：</label>
        <input type="file" id="file" name="file">
        <input type="submit" value="开始检测">
        <div class="loading"></div> <!-- 加载动画 -->
    </form>
    <form action="/exit" method="get">
        <input type="submit" value="退出">
    </form>

    <script>
        function showLoading() {
            var loading = document.querySelector('.loading');
            loading.style.display = 'block'; // 显示加载动画
        }
    </script>
</body>
</html>
